<%@ page language="java" import="java.util.*" pageEncoding="GB18030"
	import="Reservation.*,Application.Dao.*,java.text.SimpleDateFormat,DomainData.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<%
	String action = request.getParameter("action");
	UserBean user=null;
	String date="";
	String fromTime="";
	String toTime="";
	int numberOfPeople=0;
	if (action != null && action.trim().equals("checkTable")) {
		String email = request.getParameter("email");
		user = UserDAO.loadByEmail("'" + email + "'");
		fromTime = request.getParameter("fromTime");
		toTime = request.getParameter("toTime");
		date = request.getParameter("date");
		
		SimpleDateFormat formatter = new SimpleDateFormat(
				"yyyy-MM-dd HH:mm:ss");
		Date from = formatter.parse(date + " " + fromTime);
		Date to = formatter.parse(date + " " + toTime);
		System.out.println(from.toString() + to.toString());
		numberOfPeople = Integer.parseInt(request
				.getParameter("numberOfPeople"));
		int table = ReservationDAO.getTable(from, to, numberOfPeople);

		Reservation res = new Reservation(-1, from, to, numberOfPeople,
				table, user.getUserID());
		int resId = ReservationDAO.insertReservation(res);
		System.out.println(resId); 
	}
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link href="css/general.css" rel="stylesheet" type="text/css" />
<script src="js/jquery-1.6.2.min.js" type="text/javascript"	charset="utf-8"></script>
</head>
<body>
	<div class="mainBackground"></div>
	<div id="maincontent" class="center">
		<p>&nbsp;</p>	
		<h2>Your Reservation has been made. Thank you.</h2>
		<p>&nbsp;</p>	
		<img src="images/imagesample2.jpg" width="250" height="150" alt="imag" class="leftalign" />
		
		<table id="reservation_confirm" width="448" height="294" border="0">
		  <tr>
		    <td   bgcolor="#FFFCB3" width="153"><div align="left">Customer Name: </div></td>
		    <td  bgcolor="#FFFCB3" width="279">
		    	<div align="left"><%=user.getFirstName()+" "+user.getLastName()%> 
		    	</div>
		    </td>
		  </tr>
		  <tr>
		    <td  bgcolor="#FFFCB3"><div align="left">Start Time: </div></td>
		    <td bgcolor="#FFFCB3">
		    	<div align="left"><%=date + " " + fromTime %></div>
		    </td>
		  </tr>
		  <tr>
		    <td  bgcolor="#FFFCB3"><div align="left">End Time:</div> </td>
		    <td  bgcolor="#FFFCB3"><div align="left"><%=date + " " + toTime %></div></td>
		  </tr>
		  <tr>
		    <td  bgcolor="#FFFCB3"><div align="left">Number of People</div> </td>
		    <td  bgcolor="#FFFCB3"><div align="left"><%=numberOfPeople %></div></td>
		  </tr>
		   <tr>
		    <td>Order Food Now ==>></td>
		    <td><div align="center"><a href="AdminOrderFood.jsp?rid=10" ><img src="images/orderFood.png" width="100" height="125" /></a></div></td>
		  </tr>
		  
		</table>	
			<p>&nbsp;</p>	
			<p>&nbsp;</p>	
	</div>
	<div class="clear"></div>
	
	<div id="footer">
		&copy; K&G Restaurant | all Rights Reserved by CSE 333 <span
			class="credit"><a
			href="http://www.weibo.com/gaotaojie/profile?topnav=1&wvr=4">Taojie
				Gao's Paradise</a> by Taojie Gao</span>

	</div>
</body>
</html>